Repository navigation
Studio: Windows foundations — the event log's own lock file, and LF checkouts (#805) - #815
Merged
Merged
Conversation
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CVqACdL6QruKkvHdjdYPVr
…windows-foundations
Every writer of events.jsonl (the hook, the answer hook, the server's own lines) takes events.lock beside it, then opens the log for append; the prune holds it only for the tail copy, the state file's removal and the rename. Nothing locks the log itself, the (dev, ino) same-file check goes, and the prune's replaced-log check is a length check. New law log-writers-hold-the-log-lock, with tests through the public log API, a server case for append_to, and a source scan. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CVqACdL6QruKkvHdjdYPVr
…nto issue-811-studio-the-event-log
The law's scan reads statement by statement and cuts only inline test modules, so a writer naming the log through `event_log(` or placed after `#[cfg(test)] mod tests;` is caught. The two held-lock append tests are one table. The lock's path is `studio_hook::lock_file`, and the tests hold the lock through `studio_hook::locked`. The hook's main takes the log's path from `event_log_in`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CVqACdL6QruKkvHdjdYPVr
danielrispler
marked this pull request as ready for review
November 28, 2026 16:08
This was referenced Nov 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #805
Closes #811
Closes #812
Spec #805's integration branch. Its third ticket, #813 (the Rust test fake and
docs/studio/research/windows.md), is its own PR, #816, since it needed theubuntujob.Summary
#811: the event log gets its own lock file.
events.locksits besideevents.jsonl, and nothing locks the log itself any more, so a reader never meets a lock (on Windows a lock on the log blocks reads).hook/src/answer.rsandhook/src/main.rstake the log's path from the log code (event_log_in), sohook/src/lib.rsis the only file that names it.log-writers-hold-the-log-lock(on: hook,backing: check), backed by a source scan: a statement outsidehook/src/lib.rsthat names the log (events.jsonl,EVENT_LOG,event_log(,event_log_in() and opens a file to write (OpenOptions,File::create,fs::write) fails it. Inline test modules are cut; a#[cfg(test)] mod tests;line is not.docs/studio/behaviour/storage.mdstates the rule.#812: LF checkouts. A new
.gitattributes(* text=auto eol=lf,binaryfor png, jpg, gif, ico and webp), listed insystem-map.json'signored.Evidence
Tests tagged
@law: log-writers-hold-the-log-lock(hook/tests/prune.rsunless named), each run red against the old code with an assertion failure, except the threads case (the old code already gave whole lines; it went red against a mutation that wrote each line in two unlocked parts):The scan went red against both mutations the correctness pass found it missed, in a dropped WIP commit:
OpenOptions::new().append(true).open(studio_hook::event_log(home))inserver/src/learning.rs, andfs::write(studio_hook::event_log(home), "")after#[cfg(test)] mod tests;inserver/src/lib.rs. It names["server/src/learning.rs", "server/src/lib.rs"]. A path bound to a variable in one statement and opened in the next still gets past it.Moved to holding
events.lock: the deadline test above, the Cursor case inhook/tests/harness_trees.rs, and the prune case. The OpenCode case works unchanged throughstudio_hook::locked.Tests merged:
while_the_lock_is_held_the_log_reads_whole_and_an_append_waits_then_landsandan_append_whose_patience_is_shorter_than_the_hold_writes_nothingbecame the two rows ofan_append_against_a_held_lock_lands_once_it_is_let_go_or_writes_nothing_when_its_patience_runs_out. None removed.git ls-files --eol | awk '{print $1, $2}' | sort | uniq -c, the same before and after.gitattributes:After it, every text file is
attr/text=auto eol=lfand the 6 imagesattr/-text.git add --renormalize .thengit status --shortshowed only.gitattributesandsystem-map.json.npm run checkpasses on the tip2e85eff2f. In the review-fix implementer's run,ui/tests/check-slot.test.mjs"four checks run two at a time…" failed once (SyntaxError: Unexpected end of JSON input), on code this diff doesn't touch. It passed on its one rerun, and again in the merger's full check.Correctness pass
A reviewer traced every writer, the prune, the lock order and stored data both ways, ran
cargo nextest run -p studio-hook(89/89) and the server's lock and read-loop tests, and tried mutations against the scan.event_log(), and anything after a file's first#[cfg(test)](line 6 of 368 insystem-map/src/extract/mod.rs). The spec review had reported the second one already."events.lock"and its open chain were spelled out in four files, now onlyhook/src/lib.rs(studio_hook::lock_file, and the tests hold it throughstudio_hook::locked).hook/src/main.rsnamedEVENT_LOG.docs/studio/development.mdwas missing the server test, andprune.rs's header comment was out of date.events.jsonlitself, so the new prune doesn't wait for it. If the first prune of the new build swaps the log between that hook's(dev, ino)check and its write, the line goes to the replaced file, with nodrops.txtentry. The reviewer reproduced it with a scratch test. The window is microseconds in one restart, and a swap happens only when the log's first line is over 30 days old. Spec Q2 accepted the in-flight old hook, though its reasoning covered two writers, not a prune. The fix would be for the prune to lockevents.jsonltoo, for one release.deadline.rsreading the log withunwrap_or_default(correct: the log is created only under the lock now).Outside review
gemini-4-neon-medium, one round on
e4f972706. cost: 3.5 min, 190564 tokens; Gemini quota left: weekly 47% to 46%, 5h 100% to 97%server/src/read_loop.rs:219(Follower::start_at) is the prune's only caller, and it runs once per start under the data folder's lock (server/src/lock.rs), so two prunes never overlap. The correctness pass had reported it too, with the same conclusion.Merge Danger
Door: two-way
No stored format changes: an old data folder gets
events.lockon its first write, and its log, archive and state read as before. Rolling back leaves anevents.locknobody reads.Blast Radius: the event log
Every writer of
events.jsonlchanges how it locks. The one gap is the restart window above.Route outcome: #811 strong·high claude/opus → pass; #812 medium·medium claude/sonnet → pass; review fixes strong·high claude/opus → pass. Medium UI tickets so far: none in this spec.
🤖 Generated with Claude Code
https://claude.ai/code/session_01CVqACdL6QruKkvHdjdYPVr